/**
 * @fileoverview
 * TODO doc me
 */

var log = YAHOO.log;

function initialiseApplication() {
	
	var logReader = new YAHOO.widget.LogReader("logger");
	
	log("instantiate a service for the genefinder widget");
	var service = new flyui.flybase.Service("../../../data/flybase");
	
	log("instantiate a renderer for the genefinder widget");
	var renderPane = document.getElementById("genefinderWidget");
	var renderer = new flyui.genefinder.DefaultRenderer();
	renderer.setCanvas(renderPane);
	
	log("instantiate a genefinder widget");
	genefinder = new flyui.genefinder.Widget(service, renderer);
	
	log("hook form submission to widget call");
	YAHOO.util.Event.addListener("queryForm", "submit", onFormSubmit);
	
	log("application loaded, showing main pane");
	flyui.mvcutils.hide(document.getElementById("loadingPane"));
	flyui.mvcutils.show(document.getElementById("applicationPane"));
}

function onFormSubmit(event) {
	log("form submitted");
	var query = document.getElementById("queryInput").value;
	var caseSensitive = document.getElementById("caseSensitiveInput").checked;
	log("case sensitive: "+caseSensitive);
	genefinder.findGenesByAnyName(query, caseSensitive);
}

YAHOO.util.Event.onDOMReady(initialiseApplication);